const app = getApp();
const AJAX = app.$ajax,
  $wx = app.$wx;

Page({
  data: {
    productionInfo: {},
    productionIndex: 0
  },
  
  onLoad(){
    this.getRemmadDing();
  },

  onShareAppMessage() {

  },

  viewProductionImg(e) {
    let ed = e.currentTarget.dataset;
    let productionImgs = [];
    
    ed.imgs.forEach((item, index) => {
      productionImgs.push(item.images);
    });

    wx.previewImage({
      current: ed.item,
      urls: productionImgs
    });
  },

  viewCustomization(e){
    let ed = e.currentTarget.dataset;
    wx.navigateTo({
      url: '/pages/subpage/custom-made/detail/detail?detail_id=' + ed.id
    })
  },

  topProductionImg(e) {
    let ed = e.currentTarget.dataset;
    this.setData({
      productionIndex: ed.index,
      productionInfo: ed.item
    });
  },

  getRemmadDing(){
    AJAX.getRemmadDing({
      loadType: 'bar'
    }).then(([status, res, msg]) => {
      if(status){
        this.setData({
          themeList: res,
          productionInfo: res[0]
        });
      }else{
        $wx.showToast(msg);
      }
    });
  }
});